#include <srs_kernel_buffer.hpp>

#include <srs_kernel_error.hpp>
#include <srs_kernel_log.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_core_performance.hpp>

SrsSimpleBuffer::SrsSimpleBuffer() {
}

SrsSimpleBuffer::~SrsSimpleBuffer() {
}

int SrsSimpleBuffer::length() {
    return (int)data.size();
}

char* SrsSimpleBuffer::bytes() {
    return (length() == 0) ? NULL : &data.at(0);
}

void SrsSimpleBuffer::erase(int size) {
    if (size <= 0) {
        return;
    }

    if (size >= length()) {
        data.clear();
        return;
    }

    data.erase(data.begin(), data.begin() + size);
}

void SrsSimpleBuffer::append(const char* bytes, int size) {
    if (size > 0) {
        data.insert(data.end(), bytes, bytes + size);
    }
}
